package com.glorystone.ins.domain;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * Created by wangwei on 2018/3/7.
 *
 * @author wangwei
 */
public @Data @NoArgsConstructor @AllArgsConstructor @Builder class AuditTask {

    /**
     * db - model
     */
    private Long tid;
    private String name;
    private Integer status;
    private Integer flowId;
    private Integer nodeId;
    private Integer businessType;
    private Long businessId;
    private String url;
    private String permissionCode;
    private Long submitBy;
    @JsonSerialize(using = CustomLocalDateTimeSerializer.class)
    private LocalDateTime submitAt;
    private Long auditBy;
    private Integer auditResult;
    @JsonSerialize(using = CustomLocalDateTimeSerializer.class)
    private LocalDateTime auditAt;



    /**
     * params
     */
    private SysUser auditUser;
    private SysUser submitUser;


    public enum AuditTaskStatusEnum {
        /**
         * 待审
         */
        TO_DO(1),

        /**
         * 提醒，待查看
         */
        WAIT_VIEW(3),

        /**
         * 已审
         */
        DONE(2);

        private int value;

        AuditTaskStatusEnum(int value) {

            this.value = value;
        }

        public int getValue() {
            return value;
        }

    }

    public enum AuditResultEnum {
        PASS(1), REJECT(2);

        private int value;

        AuditResultEnum(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }


    }

    public void cleanAudit() {
        setAuditAt(null);
        setAuditResult(null);
        setAuditBy(null);
    }


}
